//导入request.js 工具
import request from "@/utils/request";



//题目类型列表查询
export const questionTypeListService = () => {
  // const tokenStore = useTokenStore()//创建仓库
  // // 在pinia中定义的响应式数据，能直接使用，不用value
  // return request.get('/questiontype/find',{headers:{'Authorization':tokenStore.token}}) //这个请求的路径要与后端对应
  return request.get("/questiontype/find");
};


export const questionTypeAddService = (questionTypeData) => {
  return  request.post('/questiontype/add',questionTypeData);//直接将数据以json的格式传输进去 
};

export const questionTypeUpdateService = (questionTypeData) => {
  return  request.put('/questiontype/update',questionTypeData);
};

export const questionTypeDeleteService = (id) => {
  return  request.delete('/questiontype/delete?id='+id);
};
//题目列表分页查询
export const questionListService = (params) => {
  return request.get('/question/findPageAll',{params:params});//两个params ，前面的是固定的，后面是自己传的参数
};
//题目添加提交
export const questionAddService = (questionData) => {
  return  request.post('/question/add',questionData);//直接将数据以json的格式传输进去 
};

//题目修改提交
export const questionUpdateService = (questionData) => {
  return  request.put('/question/update',questionData);
};
//删除题目
export const questionDeleteService = (id) => {
  return  request.delete('/question/delete?id='+id);
};
//批量删除题目
export const questionBatchDeleteService = (multipleSelection) => {
  return request.put('/question/batchDelete', multipleSelection );
};
export const expQuestionServer =()=>{
  return request({
    url: "/question/export",
    method: 'get',
    responseType: 'blob' // 设置响应类型为blob
  });
}
export const QuestionUploadService= (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: "/question/upload",
    method: 'post',
    data: formData, // 使用 data 而不是 formData
    headers: {
      'Content-Type': undefined // 让 axios 自动设置 Content-Type
    }
  });
};
//首页查询所有数量及类型 
export const  questionCountServer =()=>{
  return request.get('/question/findAllQuestionAndCount');
}

//首页查询全部数量
export const  questionAllCountServer =()=>{
  return request.get('/question/findAllCount');
}

